package com.tuniu.agents.impl.trip;

import com.tuniu.agents.agent.AgentManagerGroup;
import com.tuniu.agents.impl.train.logger.TrainAgentLoggingService;
import com.tuniu.agents.message.MessageLogger;
import com.tuniu.agents.message.MessageSender;
import lombok.SneakyThrows;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class PlannerConfig {

    @Autowired
    private MessageSender messageSender;
    public static final String PLANNER_AGENT_PROMPT_TEMPLATE_ID = "planner";

    @Bean(Planner.AGENT_ID)
    @SneakyThrows
    public Planner planner(AgentManagerGroup agentManagerGroup, @Qualifier("DEEPSEEK_R1") ChatOptions chatOptions) {
        MessageLogger logger = new MessageLogger(TrainAgentLoggingService.BEAN_NAME);
        return new Planner(agentManagerGroup, Planner.AGENT_ID, PLANNER_AGENT_PROMPT_TEMPLATE_ID, chatOptions, new PlannerStreamResponseHandler(agentManagerGroup.getChatEnvironmentMemory(), agentManagerGroup.getAgentManager(), messageSender, agentManagerGroup.getMemoryManager()));
    }

}
